package org.itboys.core.controller.web;

import org.itboys.commons.CommonConstants;
import org.itboys.commons.dto.ResultPageDOHelper;
import org.itboys.commons.utils.ajax.AjaxUtils;
import org.itboys.core.entity.mysql.SundayStoreAdd;
import org.itboys.core.service.mysql.web.SundayStoreAddService;
import org.itboys.framework.query.JsonPageUtils;
import org.itboys.framework.spring.controller.BaseController;
import org.itboys.param.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author：贾琦磊
 * @Date：2018/8/23
 * @Description：库存增量
 */
@Controller
@RequestMapping("/sunday/web/store/add")
public class SundayStoreAddController extends BaseController{
    @Autowired
    private SundayStoreAddService storeAddService;
    @RequestMapping("/index" )
    public  String index(HttpServletRequest request){
        return "/sunday/store/add/index";
    }

    @RequestMapping("/input" )
    public  String input(HttpServletRequest request
            ,@RequestParam("id") Long id
            ,Model model){
       // model.addAttribute("store",storeAddService.getById(id));
        return "/sunday/store/input";
    }
    @RequestMapping("/select")
    public void select(HttpServletRequest request
            , HttpServletResponse response){
        try {
            PageResult<SundayStoreAdd> result = storeAddService.select(request);
            JsonPageUtils.renderJsonPage(result.getTotal(),result.getData(),response);
        } catch (Exception e) {
            e.printStackTrace();
            AjaxUtils.renderJsonporJson(response, null,
                    ResultPageDOHelper.getMsgCodeResultDO(CommonConstants.FAIL_CODE, CommonConstants.FAIL));
        }
    }

}
